<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" v-show="showSearch" >

      <!--RAG Lab ID-->
      <el-form-item prop="ragLabId">
        <el-input
          v-model="queryParams.ragLabId"
          placeholder="Pls input ragLabId"
          clearable
        />
      </el-form-item>

      <!--Standard ID-->
      <el-form-item prop="standardId">
        <el-input
          v-model="queryParams.standardId"
          placeholder="Pls input standardId"
          clearable
        />
      </el-form-item>

      <!--Status-->
      <el-form-item prop="status">
        <el-select v-model="queryParams.status" placeholder="Select Status" clearable>
          <el-option
            v-for="dict in dict.type.llm_lab_result_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <!--Match Level-->      
      <el-form-item prop="matchLevel">
        <el-select v-model="queryParams.matchLevel" placeholder="Select Level" clearable>
          <el-option
            v-for="dict in dict.type.ade_match_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">Search</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">Reset</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['ade:raglabresult:export']"
        >Export</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="raglabresultList">
      <el-table-column label="ID" width="60" align="center" prop="id" />
      <el-table-column label="RAG Lab" width="80" align="center" prop="ragLabId" />
      <el-table-column label="Standard" width="80" align="center" prop="standardId" />
      <el-table-column label="Standard Ades" min-width="200" align="left" prop="standardAdes" show-overflow-tooltip/>
      <el-table-column label="Ades" align="left" min-width="200" prop="ades" show-overflow-tooltip/>
       <el-table-column label="Match Level" align="center" prop="matchLevel" />
      <el-table-column label="TC(S)" width="100" align="center" prop="timeConsumed" />
      <el-table-column label="Knowledges" align="center" prop="knowledgeCount" />
      <el-table-column label="Avg SimScore" align="center" prop="avgSimscore" />
      <el-table-column label="Status" align="center" prop="status">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.llm_lab_result_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="Remark" align="center" prop="remark" show-overflow-tooltip/>
      
     
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改Ade Rag Lab Result对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="RAG Lab ID" prop="ragLabId">
          <el-input v-model="form.ragLabId" placeholder="请输入RAG Lab ID" />
        </el-form-item>
        <el-form-item label="Standard ID" prop="standardId">
          <el-input v-model="form.standardId" placeholder="请输入Standard ID" />
        </el-form-item>
        <el-form-item label="Ades" prop="ades">
          <el-input v-model="form.ades" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="Remark" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="Time Consumed" prop="timeConsumed">
          <el-input v-model="form.timeConsumed" placeholder="请输入Time Consumed" />
        </el-form-item>
        <el-form-item label="Avg SimScore" prop="avgSimscore">
          <el-input v-model="form.avgSimscore" placeholder="请输入Avg SimScore" />
        </el-form-item>
        <el-form-item label="Status 1-finished 0-exception" prop="status">
          <el-select v-model="form.status" placeholder="请选择Status 1-finished 0-exception">
            <el-option
              v-for="dict in dict.type.llm_lab_result_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="Knowledges" prop="knowledgeCount">
          <el-input v-model="form.knowledgeCount" placeholder="请输入Knowledges" />
        </el-form-item>
        <el-form-item label="Match Level" prop="matchLevel">
          <el-input v-model="form.matchLevel" placeholder="请输入Match Level" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listRaglabresult, getRaglabresult, delRaglabresult, addRaglabresult, updateRaglabresult } from "@/api/ade/raglabresult";

export default {
  name: "Raglabresult",
  dicts: ['llm_lab_result_status',
    'ade_match_level'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // Ade Rag Lab Result表格数据
      raglabresultList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ragLabId: null,
        standardId: null,
        ades: null,
        timeConsumed: null,
        avgSimscore: null,
        status: null,
        knowledgeCount: null,
        matchLevel: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        ragLabId: [
          { required: true, message: "RAG Lab ID不能为空", trigger: "blur" }
        ],
        standardId: [
          { required: true, message: "Standard ID不能为空", trigger: "blur" }
        ],
        ades: [
          { required: true, message: "Ades不能为空", trigger: "blur" }
        ],
        status: [
          { required: true, message: "Status 1-finished 0-exception不能为空", trigger: "change" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询Ade Rag Lab Result列表 */
    getList() {
      this.loading = true;
      listRaglabresult(this.queryParams).then(response => {
        this.raglabresultList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        ragLabId: null,
        standardId: null,
        ades: null,
        remark: null,
        timeConsumed: null,
        avgSimscore: null,
        createTime: null,
        status: null,
        knowledgeCount: null,
        matchLevel: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加Ade Rag Lab Result";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getRaglabresult(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改Ade Rag Lab Result";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateRaglabresult(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addRaglabresult(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除Ade Rag Lab Result编号为"' + ids + '"的数据项？').then(function() {
        return delRaglabresult(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('ade/raglabresult/export', {
        ...this.queryParams
      }, `raglabresult_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
